package MeteoCal.utility;

import MeteoCal.bean.EventBean;
import MeteoCal.entity.User;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;

/**
 *
 * @authors Guttadoro, Iommazzo, Saullo
 */
@ManagedBean
public class AutoCompleteView_Event {
    
    @ManagedProperty("#{eventBean}")
    private EventBean service;
         
   // private List<User> selectedThemes;
    
    public List<User> completeTheme(String query) {
        List<User> allThemes = service.getUsers();
        List<User> filteredThemes = new ArrayList<>();
            
        for (User skin : allThemes) {
            if(skin.getEmail().toLowerCase().contains(query.toLowerCase()) ||
                    skin.getName().toLowerCase().contains(query.toLowerCase())||
                    skin.getSurname().toLowerCase().contains(query.toLowerCase())) {
                filteredThemes.add(skin);
            }
        } 
         
        return filteredThemes;
    }
     
    public void setService(EventBean service) {
        this.service = service;
    }
 
}
